package com.citywy.client;

import com.citywy.dao.AccountDao;
import com.citywy.service.AccountService;
import com.citywy.service.impl.AccountServiceImpl;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * 模拟表现出，调用业务层
 */
public class Client {
    public static void main(String[] args) {
        //1.获取核心容器对象
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        //2.根据ID获取Bean对象
        AccountService as = (AccountService) context.getBean("accountService");
        AccountService as2 = (AccountService) context.getBean("accountService");
        System.out.println("输出："+(as==as2));
        as.saveAccount();
        System.out.println(as);

//        AccountDao ad=(AccountDao) context.getBean("accountDao");
//        ad.saveAccount();
    }
}
